import request from '@/utils/request'

// 获取推广返利列表
export function getAffiliateList(params) {
  return request({
    url: '/bg/affiliate/list',
    method: 'get',
    params
  })
}

// 获取推广返利详情
export function getAffiliateDetail(userId) {
  return request({
    url: `/bg/affiliate/detail/${userId}`,
    method: 'get'
  })
}

// 更新推广状态
export function updateAffiliateStatus(userId, status) {
  return request({
    url: `/bg/affiliate/status/${userId}`,
    method: 'put',
    data: { status }
  })
}

// 结算返利
export function settleCommission(commissionId) {
  return request({
    url: `/bg/affiliate/commission/settle/${commissionId}`,
    method: 'put'
  })
}

// 取消返利
export function cancelCommission(commissionId) {
  return request({
    url: `/bg/affiliate/commission/cancel/${commissionId}`,
    method: 'put'
  })
}

// 批量结算返利
export function batchSettleCommission(userId) {
  return request({
    url: `/bg/affiliate/commission/batch-settle/${userId}`,
    method: 'put'
  })
}

// 更新支付宝信息
export function updateAliPayInfo(userId, data) {
  return request({
    url: `/bg/affiliate/ali-pay-info/${userId}`,
    method: 'put',
    data
  })
}
